home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 28 / develop issue 28 code / sketch / source / appleevent / oslhelpers.h < prev   
Encoding:
C/C++ Source or Header  |  1996-08-24  |  6.6 KB  |  166 lines

  1. /****************************************************************************
  2.  * 
  3.  * OSLHelpers.h
  4.  * 
  5.  * Functions related to supporting the OSL suites
  6.  *
  7.  ****************************************************************************/
  8.  
  9. #ifndef __OSLHELPERS__
  10. #define __OSLHELPERS__
  11.  
  12. #include    <AEObjects.h>
  13. #include    <stdarg.h>
  14. #include    <AERegistry.h>
  15.  
  16. #include "Structs.h"
  17.  
  18. // ----------------------------------------------------------------------------
  19. // define our unique property codes
  20. // These must also be defined in the 'aete' resource, and they should
  21. // also be added to the TMPL resource that Resourcer uses for the aete parsing.
  22. // The leading 'p' indicates a property, and I use a capital 2nd letter
  23. // because Apple reserves all-lowercase types for its own use.
  24.  
  25. #define pObjectType                'pObT'
  26. #define pProperties                'qpro'    // enum is from Apple, but they forgot to define pProperties
  27.  
  28. #define pWidth                        'pWth'    // the width  of a graphic object
  29. #define pHeight                    'pHth'   // the height of a graphic object
  30. #define pLocation                    'pLcn'   // the upper left corner of the object's bounding box
  31.  
  32. // Stroke extensions
  33.  
  34. #define pStrokeSize            'pSSz'    // "stroke size"
  35. #define pStrokeColor           'pSCo'    // "stroke color"
  36.  
  37. // Windows
  38. #define pTitle                        'pTit'
  39. #define pIsModeless                'pNMo'
  40. #define pIsMovableModal       'pMMo'
  41. #define pIsSuspended                'pSus'
  42. #define pIsPalette                'pPal'
  43. #define pIsDialog                    'pDlg'
  44.  
  45. // Application 
  46.  
  47. #define pFreeMemory                'pMem'
  48. #define pLargestFreeBlock        'pLFB'
  49. #define pTicks                        'pTic'
  50.  
  51. // Miscellaneour Suite extra events
  52.  
  53. #define kAEPlaySound                'plsn'
  54. #define kAESay                        'SAY '
  55.  
  56. //---------------------------------------------------------------------------
  57.  
  58. typedef struct ColorRecord
  59. {
  60.     char *        name;
  61.     DescType        code;
  62.     RGBColor        rgbValue;
  63. } ColorRecord;
  64.  
  65. Boolean    GetColorRecordByName    (char    *name,         ColorRecord *colorRecord);
  66. Boolean    GetColorRecordByCode    (DescType code,         ColorRecord *colorRecord);
  67. Boolean    GetColorRecordByRGB    (RGBColor rgbValue,    ColorRecord *colorRecord);
  68.  
  69. //---------------------------------------------------------------------------
  70.  
  71. OSErr    GetMissingParams        (AppleEvent* appleEvent);
  72. void    ReportError                (AppleEvent* reply, long err);
  73.  
  74. //---------------------------------------------------------------------------
  75. // Extract AEDesc data and store into native data types
  76.  
  77. OSErr     DescToDescType        (const AEDesc *desc, DescType*        descType);
  78. OSErr     DescToBoolean        (const AEDesc* desc, Boolean*         aBoolean);
  79.  
  80. OSErr     DescToShort            (const AEDesc* desc, short*             aShort);
  81. OSErr     DescToLong            (const AEDesc* desc, long*             aLong);
  82. OSErr     DescToFloat            (const AEDesc* desc, float*             aFloat);
  83. OSErr     DescToFixed            (const AEDesc* desc, Fixed*             aFixed);
  84. OSErr     DescToShortDouble    (const AEDesc* desc, short double*     aFloat);
  85.  
  86. OSErr     DescToPoint            (const AEDesc* desc, Point*             aPoint);
  87. OSErr     DescToRect            (const AEDesc* desc, Rect*             aRect);
  88.  
  89. OSErr     DescToRGBColor        (const AEDesc* desc, RGBColor*         aRGBColor);
  90.  
  91. OSErr     DescToPString        (const AEDesc* desc, Str255             aPString,     short maxLength);
  92. OSErr     DescToTextHandle    (const AEDesc* desc, Handle             *text);
  93. OSErr        DescToOSARange        (const AEDesc *desc, short             *start,         short *end);
  94.  
  95. //---------------------------------------------------------------------------
  96. //                                    Token-related Helper functions
  97. //---------------------------------------------------------------------------
  98.  
  99. DescType            ExtractDispatchClassFromToken        (const AEDesc *token);
  100. DescType            ExtractObjectClassFromToken        (const AEDesc *token);
  101. Boolean            ExtractUsePropertyCodeFromToken    (const AEDesc *token);    // emulated
  102. DescType            ExtractPropertyCodeFromToken        (const AEDesc *token);
  103. long                ExtractDocumentNumberFromToken    (const AEDesc *token);
  104. long                ExtractElementNumberFromToken        (const AEDesc *token);
  105. WindowPtr       ExtractWindowPtrFromToken            (const AEDesc *token);
  106.  
  107. OSErr                GetDocumentReferenceFromToken        (const AEDesc *token, DocumentReference *document);
  108. OSErr             GetElementReferenceFromToken        (const AEDesc *token, ElementReference *element);
  109.  
  110. //----------------------------------------------------------------------------------
  111.  
  112. OSErr     ExtractKeyDataParameter                  (const AppleEvent *appleEvent, AEDesc *data);
  113. OSErr     ResolveObjectSpecifier                  (const AEDesc *source, AEDesc *data);
  114. OSErr        ExtractData                                    (const AEDesc     *sourceDesc, AEDesc *data);
  115.  
  116. // ----------------------------------------------------------------------------------------
  117. //                            Callback & Coercion support
  118. // ----------------------------------------------------------------------------------------
  119.  
  120. Boolean    InstallCoercionHandlers                (void);
  121. Boolean    InstallObjectCallbackFunctions    (void);
  122.  
  123. //----------------------------------------------------------------------------------
  124. //                         Object Specifier Helpers for supported objects
  125. //----------------------------------------------------------------------------------
  126.  
  127.  
  128. OSErr     CreateDocumentOSpec                    (DocumentReference document,                                         AEDesc *ospec);
  129.  
  130. OSErr     CreateElementOSpec                    (DocumentReference document, ElementReference element,     AEDesc *ospec);
  131. OSErr     CreateElementUniqueIDOSpec            (DocumentReference document, ElementReference element,     AEDesc *ospec);
  132.  
  133. OSErr     CreateGraphicObjectOSpec            (DocumentReference document, ElementReference element,     AEDesc *ospec);
  134. OSErr     CreateGraphicGroupMemberOSpec        (DocumentReference document, ElementReference element,     ElementReference subElement, AEDesc *ospec);
  135.  
  136. OSErr        CreateRangeDescriptorOSpec            (const AEDesc* container, DescType desiredClass, long index1, long index2, AEDesc *ospec);
  137.  
  138. //----------------------------------------------------------------------------------
  139.  
  140. void        ExamineOSpec                            (AEDesc *ospec);
  141. void         ExamineAEResolveError                (OSErr errorFromAEResolve);
  142.  
  143. //----------------------------------------------------------------------------------
  144.  
  145. Boolean     TokenContainsTokenList                (AEDesc *token);
  146. OSErr     GetFirstNonListToken                    (AEDesc *token, AEDesc *result);
  147.  
  148. OSErr     FlattenAEList                            (AEDescList *deepList, AEDescList *flatList);
  149.  
  150. //----------------------------------------------------------------------------------
  151.  
  152. Boolean     EqualRGB                                    (RGBColor colorA, RGBColor colorB);
  153.  
  154. //----------------------------------------------------------------------------------
  155.  
  156. Boolean    InstallCoercionHandlers                (void);
  157.  
  158. //----------------------------------------------------------------------------------
  159.  
  160. OSErr        NormalizeAbsoluteIndex                (const AEDesc *keyData, long *index, long maxIndex, Boolean *isAllItems);
  161. OSErr     ProcessFormRange                        (AEDesc *keyData, AEDesc *startObject, AEDesc *stopObject);
  162.  
  163. //----------------------------------------------------------------------------------
  164.  
  165. #endif
  166.